import React from 'react'
import ReactDOM from 'react-dom'
import { BrowserRouter, Switch, Route } from 'react-router-dom'
import {createStore,applyMiddleware,compose} from 'redux'
import thunk from 'redux-thunk' // 中间件，处理异步操作
import {Provider} from 'react-redux'


import Login from './container/login/login'
import Register from './container/register/register'
import AutoRoute from './components/autoroute/autoroute'
import Home from './components/home/home'
import Dashboard from './components/dashboard/dashboard'
import reducers from './reducer'
import './index.css'
import './config'

const reduxDevtools = window.devToolsExtension ? window.devToolsExtension() : () => {} // redux在浏览器中的调试
const store = createStore(reducers, compose( // 组合函数
    applyMiddleware(thunk),  // 将中间件与redux连接起来
    reduxDevtools
))




ReactDOM.render(
    (<Provider store={store}>
        <BrowserRouter>
            <div>
                <AutoRoute></AutoRoute>
                <Switch>
                    <Route component={Dashboard}/>             
                </Switch>
            </div>
        </BrowserRouter>
    </Provider>),
    document.getElementById('root')
)

